package com.yichuang.wuziqi.player;

import com.yichuang.wuziqi.domain.Data;
import com.yichuang.wuziqi.tool.JsonTools;
import com.yichuang.wuziqi.view.BoardPanel;

/**
 * Created by xcm on 17-11-27.
 */

public class LocalPlayer extends Player {

    private BoardPanel panel;

    public LocalPlayer(BoardPanel panel) {
        this.panel = panel;
    }

    public LocalPlayer(int side, BoardPanel panel) {
        super(side);
        this.panel = panel;
    }

    @Override
    public Data oneStep(Data data) {
        int type = data.getType();
        switch (type) {
            case Data.PlayerAction.PLAYER_DROP:
                return new Data(Data.PlayerAction.PLAYER_DROP, JsonTools.toJSONString(panel.getDrop()));
            case Data.ServerAction.GAME_START:
                if (data.getData().equals(Player.FIRST_SIDE + "")) {
                    return new Data(Data.PlayerAction.PLAYER_DROP, JsonTools.toJSONString(panel.getDrop()));
                }
                break;
        }
        return null;
    }
}
